﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Termites
{
    abstract class Level
    {
        protected List<Termite> computerTermites;
        public List<Termite> ComputerTermites
        {
            get { return computerTermites; }
            set { computerTermites = value; }
        }

        protected BoundingSphere baseBoundingSphere;
        public BoundingSphere BaseBoundingSphere
        {
            get { return baseBoundingSphere; }
            set { baseBoundingSphere = value; }
        }

        protected Termite player;
        public Termite Player
        {
            get { return player; }
            set { player = value; }
        }

        protected List<Behavior> termiteBehaviors;
        protected int levelWidth;
        protected int levelHeight;

        protected float termitScale;
        public float TermitScale
        {
            get { return termitScale; }
            set { termitScale = value; }
        }

        public Level(BoundingSphere basePos, Texture2D tTexture, float scale, int levelWidth, int levelHeight)
        {
            this.baseBoundingSphere = basePos;
            this.computerTermites = new List<Termite>();
            this.player = new Termite(true, tTexture, scale);
            this.termiteBehaviors = new List<Behavior>();
            this.levelWidth = levelWidth;
            this.levelHeight = levelHeight;
            this.termitScale = scale;
        }

        public bool isPlayerInGoal()
        {
            return this.player.BoundingBox.Intersects(baseBoundingSphere);
        }

        protected void RandomlyPositionTermites()
        {
            Random r = new Random();
            foreach (Termite termite in computerTermites)
            {
                float xPosition = r.Next(levelWidth);
                float yPosition = r.Next(levelHeight);
                Vector2 termitePosition = termite.Position;
                termitePosition.X = xPosition;
                termitePosition.Y = yPosition;
                termite.Position = termitePosition;
            }

        }
    }
}
